package cn.iocoder.yudao.module.reclaim.dal.mysql.productcheckres;

import cn.iocoder.yudao.framework.common.pojo.PageResult;
import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX;
import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX;
import cn.iocoder.yudao.module.reclaim.controller.admin.productcheckdeductitem.vo.ReclaimCheckDeductItemPageReqVO;
import cn.iocoder.yudao.module.reclaim.dal.dataobject.productcheckres.ReclaimCheckDeductItemDO;
import org.apache.ibatis.annotations.Mapper;

import java.util.List;

/**
 * 回收核验扣除项 Mapper
 *
 * @author FFFF
 */
@Mapper
public interface ReclaimCheckDeductItemMapper extends BaseMapperX<ReclaimCheckDeductItemDO> {

    default List<ReclaimCheckDeductItemDO> selectListByResId(Long resId) {
        return selectList(ReclaimCheckDeductItemDO::getResId, resId);
    }

    default int deleteByResId(Long resId) {
        return delete(ReclaimCheckDeductItemDO::getResId, resId);
    }

    default PageResult<ReclaimCheckDeductItemDO> selectPage(ReclaimCheckDeductItemPageReqVO pageReqVO) {
        return selectPage(pageReqVO, new LambdaQueryWrapperX<ReclaimCheckDeductItemDO>()
                .eqIfPresent(ReclaimCheckDeductItemDO::getItemNumber, pageReqVO.getItemNumber())
                .eqIfPresent(ReclaimCheckDeductItemDO::getItemPic, pageReqVO.getItemPic())
                .eqIfPresent(ReclaimCheckDeductItemDO::getItemName, pageReqVO.getItemName())
                .eqIfPresent(ReclaimCheckDeductItemDO::getPrice, pageReqVO.getPrice())
                .eqIfPresent(ReclaimCheckDeductItemDO::getReason, pageReqVO.getReason())
                .eqIfPresent(ReclaimCheckDeductItemDO::getRemark, pageReqVO.getRemark())
                .eqIfPresent(ReclaimCheckDeductItemDO::getResId, pageReqVO.getResId())
                .eqIfPresent(ReclaimCheckDeductItemDO::getTotalPrice, pageReqVO.getTotalPrice())
                .betweenIfPresent(ReclaimCheckDeductItemDO::getCreateTime, pageReqVO.getCreateTime())
                .orderByDesc(ReclaimCheckDeductItemDO::getId));
    }
}